package com.xuecheng.search.controller;

import com.xuecheng.api.search.SearchControllerApi;
import com.xuecheng.framework.domain.course.CoursePub;
import com.xuecheng.framework.domain.course.response.TeachplanMediaPub;
import com.xuecheng.framework.domain.search.CourseSearchParam;
import com.xuecheng.framework.model.response.QueryResponseResult;
import com.xuecheng.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController implements SearchControllerApi {
    @Autowired
    SearchService searchService;

    @GetMapping("/course/list/{page}/{size}")
    @Override
    public QueryResponseResult searchIndex(@PathVariable("page") Integer page, @PathVariable("size") Integer size, CourseSearchParam courseSearchParam) {

        return searchService.searchIndex(page, size, courseSearchParam);
    }

    /**
     * @Description: 根据id查询课程全部信息
     * @Param:
     * @return:
     * @Author: Mr.Yuan
     * @Date:
     */
    @GetMapping("/course/getall/{id}")
    @Override
    public Map<String, CoursePub> findbyId(@PathVariable("id") String id) {
        return searchService.findbyId(id);
    }

    /**
     * @Description: 根据课程id查询媒资信息
     * @Param:
     * @return:
     * @Author: Mr.Yuan
     * @Date:
     */
    @GetMapping("/findMedia/{teachplanId}")
    public List<TeachplanMediaPub> findTeachplanMedia(@PathVariable("teachplanId") String teachplanId) {
        return searchService.findTeachplanMedia(teachplanId);
    }
}
